import 'dart:io';

import 'package:permission_handler/permission_handler.dart';

/// 权限工具类
class PermissionUtil {
  /// 申请摄像头权限
  static Future<bool> requestCameraPermission() async {
    await [
      Permission.camera,
    ].request();

    if (await Permission.camera.isGranted) {
      return true;
    } else {
      return false;
    }
  }

  /// 申请照片权限
  static Future<bool> requestPhotosPermission() async {
    await [
      Permission.photos,
    ].request();

    if (await Permission.photos.isGranted) {
      return true;
    } else {
      return false;
    }
  }

  /// 申请视频权限
  static Future<bool> requestVideosPermission() async {
    await [
      Permission.videos,
    ].request();

    if (await Permission.videos.isGranted) {
      return true;
    } else {
      return false;
    }
  }

  /// 申请语音权限
  static Future<bool> requestAudioPermission() async {
    await [
      Permission.audio,
    ].request();

    if (await Permission.audio.isGranted) {
      return true;
    } else {
      return false;
    }
  }
  /// 申请麦克风权限
  static Future<bool> requestMicrophonePermission() async {
    await [
      Permission.microphone,
    ].request();

    if (await Permission.microphone.isGranted) {
      return true;
    } else {
      return false;
    }
  }


  /// 申请存储权限
  static Future<bool> requestStoragePermission() async {
    await [
      Permission.storage,
    ].request();

    if (await Permission.storage.isGranted) {
      return true;
    } else {
      return false;
    }
  }
  /// 申请存储权限 13+
  static Future<bool> requestManageExternalStoragePermission() async {
    await [
      Permission.manageExternalStorage,
    ].request();

    if (await Permission.manageExternalStorage.isGranted) {
      return true;
    } else {
      return false;
    }
  }

}
